import request from '@/utils/request'

// 查询菜单列表
export function listMenu(query) {
  return request({
    url: '/system/menu/list',
    method: 'get',
    params: query
  })
}

// 查询菜单详细
export function getMenu(menuId) {
  return request({
    url: '/system/menu/' + menuId,
    method: 'get'
  })
}

// 查询菜单下拉树结构
export function treeselect(query) {
  return request({
    url: '/system/menu/treeselect',
    method: 'get',
    params: query
  })
}

// 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(query) {
  return request({
    url: '/system/menu/roleMenuTreeselect',
    method: 'get',
    params: query
  })
}

// 新增菜单
export function addMenu(data) {
  return request({
    url: '/system/menu',
    method: 'post',
    data: data
  })
}

// 修改菜单
export function updateMenu(data) {
  return request({
    url: '/system/menu',
    method: 'put',
    data: data
  })
}

// 删除菜单
export function delMenu(menuId) {
  return request({
    url: '/system/menu/' + menuId,
    method: 'delete'
  })
}

// 菜单状态修改
export function changeMenuStatus(menuId, status) {
  const data = {
    menuId,
    status
  }
  return request({
    url: '/system/menu/changeStatus',
    method: 'put',
    data: data
  })
}

// 取消授权
export function authRoleCancel(data) {
  return request({
    url: '/system/menu/authRole/cancel',
    method: 'put',
    data: data
  })
}

// 批量取消收授权
export function authRoleCancelAll(data) {
  return request({
    url: '/system/menu/authRole/cancelAll',
    method: 'put',
    params: data
  })
}

// 查询菜单未授权角色列表
export function unallocatedRoleList(query) {
  return request({
    url: '/system/menu/authRole/unallocatedRoleList',
    method: 'get',
    params: query
  })
}

// 批量授权菜单角色
export function insertAuthRoleAll(data) {
  return request({
    url: '/system/menu/authRole/insertAll',
    method: 'put',
    params: data
  })
}
